package com.app.common.dataDictionary.PO;

import java.util.BitSet;
import java.util.HashMap;
import java.util.Map;

import com.app.common.dataDictionary.DE.DE_FILE_AVAILABLE;
import com.app.common.dataDictionary.DE.DE_FILE_ID;
import com.app.common.dataDictionary.DE.DE_FILE_IMGDOMAIN;
import com.app.common.dataDictionary.DE.DE_FILE_IMGID;
import com.app.common.dataDictionary.DE.DE_FILE_IMGNAME;
import com.app.common.dataDictionary.DE.DE_FILE_IMGPATH;
import com.app.common.dataDictionary.DE.DE_FILE_IMGSIZE;
import com.app.common.dataDictionary.DE.DE_FILE_OPPTIME;
import com.app.common.dataDictionary.DE.DE_FILE_RELATEDDOCSTOREID;
import com.app.common.dataDictionary.DE.DE_FILE_RELATEDDOCTYPEID;
import com.app.common.dataDictionary.DE.DE_FILE_SFSHOW;
import com.css.sword.kernel.base.annotation.PersistObject;
import com.css.sword.kernel.base.dataElement.AbsPersistObject;
import com.css.sword.kernel.base.dataElement.BaseDataElement;
import com.css.sword.kernel.base.dataElement.DateDE;
import com.css.sword.kernel.base.exception.SwordBaseCheckedException;


/**
 * 附件表; InnoDB free: 10240 kB
 */
@PersistObject
public class TFilePO extends AbsPersistObject {
	//private static final long serialVersionUID = 2254713702835577466L;
	private static final long serialVersionUID = 1L;
	private static final BitSet HAS_DEFAULT_VALUE = new BitSet(11);
	
	static{
		HAS_DEFAULT_VALUE.set(8, true);HAS_DEFAULT_VALUE.set(9, true);
	}
	
	/**
	 * 物理表名
	 */
	public static final String TABLE_NAME = "t_file";

	/**
	 * 主键id
	 */
	private DE_FILE_ID fileId = DE_FILE_ID.getTemplateInstance();

	/**
	 * 关联的表名
	 */
	private DE_FILE_RELATEDDOCTYPEID fileRelateddoctypeid = DE_FILE_RELATEDDOCTYPEID.getTemplateInstance();

	/**
	 * 关联的表的相应字段主键id
	 */
	private DE_FILE_RELATEDDOCSTOREID fileRelateddocstoreid = DE_FILE_RELATEDDOCSTOREID.getTemplateInstance();

	/**
	 * 附件图片编号
	 */
	private DE_FILE_IMGID fileImgid = DE_FILE_IMGID.getTemplateInstance();

	/**
	 * 附件图片name
	 */
	private DE_FILE_IMGNAME fileImgname = DE_FILE_IMGNAME.getTemplateInstance();

	/**
	 * 附件图片主路径
	 */
	private DE_FILE_IMGDOMAIN fileImgdomain = DE_FILE_IMGDOMAIN.getTemplateInstance();

	/**
	 * 附件图片文件路径
	 */
	private DE_FILE_IMGPATH fileImgpath = DE_FILE_IMGPATH.getTemplateInstance();

	/**
	 * 附件图片大小
	 */
	private DE_FILE_IMGSIZE fileImgsize = DE_FILE_IMGSIZE.getTemplateInstance();

	/**
	 * 附件图片是否可用
	 */
	private DE_FILE_AVAILABLE fileAvailable = DE_FILE_AVAILABLE.getTemplateInstance();

	/**
	 * 附件图片是否显示
	 */
	private DE_FILE_SFSHOW fileSfshow = DE_FILE_SFSHOW.getTemplateInstance();

	/**
	 * 附件图片操作时间
	 */
	private DE_FILE_OPPTIME fileOpptime = DE_FILE_OPPTIME.getTemplateInstance();


	public TFilePO(){
		this.insertState = new BitSet(11);
		this.updateState = new BitSet(11);
	}

	
	/**
	 * 获取 "主键id" 值
	 */	
	public DE_FILE_ID getFileId(){
		return  fileId;
	}
	
	/**
	 * 设置 "主键id" 值
	 */
	public void setFileId(DE_FILE_ID fileId) {
		if(fileId == null){
			fileId= DE_FILE_ID.getTemplateInstance();
		}
		recordChangeFlag(0);
		this.fileId = fileId;
	}
	
	/**
	 * 获取 "关联的表名" 值
	 */	
	public DE_FILE_RELATEDDOCTYPEID getFileRelateddoctypeid(){
		return  fileRelateddoctypeid;
	}
	
	/**
	 * 设置 "关联的表名" 值
	 */
	public void setFileRelateddoctypeid(DE_FILE_RELATEDDOCTYPEID fileRelateddoctypeid) {
		if(fileRelateddoctypeid == null){
			fileRelateddoctypeid= DE_FILE_RELATEDDOCTYPEID.getTemplateInstance();
		}
		recordChangeFlag(1);
		this.fileRelateddoctypeid = fileRelateddoctypeid;
	}
	
	/**
	 * 获取 "关联的表的相应字段主键id" 值
	 */	
	public DE_FILE_RELATEDDOCSTOREID getFileRelateddocstoreid(){
		return  fileRelateddocstoreid;
	}
	
	/**
	 * 设置 "关联的表的相应字段主键id" 值
	 */
	public void setFileRelateddocstoreid(DE_FILE_RELATEDDOCSTOREID fileRelateddocstoreid) {
		if(fileRelateddocstoreid == null){
			fileRelateddocstoreid= DE_FILE_RELATEDDOCSTOREID.getTemplateInstance();
		}
		recordChangeFlag(2);
		this.fileRelateddocstoreid = fileRelateddocstoreid;
	}
	
	/**
	 * 获取 "附件图片编号" 值
	 */	
	public DE_FILE_IMGID getFileImgid(){
		return  fileImgid;
	}
	
	/**
	 * 设置 "附件图片编号" 值
	 */
	public void setFileImgid(DE_FILE_IMGID fileImgid) {
		if(fileImgid == null){
			fileImgid= DE_FILE_IMGID.getTemplateInstance();
		}
		recordChangeFlag(3);
		this.fileImgid = fileImgid;
	}
	
	/**
	 * 获取 "附件图片name" 值
	 */	
	public DE_FILE_IMGNAME getFileImgname(){
		return  fileImgname;
	}
	
	/**
	 * 设置 "附件图片name" 值
	 */
	public void setFileImgname(DE_FILE_IMGNAME fileImgname) {
		if(fileImgname == null){
			fileImgname= DE_FILE_IMGNAME.getTemplateInstance();
		}
		recordChangeFlag(4);
		this.fileImgname = fileImgname;
	}
	
	/**
	 * 获取 "附件图片主路径" 值
	 */	
	public DE_FILE_IMGDOMAIN getFileImgdomain(){
		return  fileImgdomain;
	}
	
	/**
	 * 设置 "附件图片主路径" 值
	 */
	public void setFileImgdomain(DE_FILE_IMGDOMAIN fileImgdomain) {
		if(fileImgdomain == null){
			fileImgdomain= DE_FILE_IMGDOMAIN.getTemplateInstance();
		}
		recordChangeFlag(5);
		this.fileImgdomain = fileImgdomain;
	}
	
	/**
	 * 获取 "附件图片文件路径" 值
	 */	
	public DE_FILE_IMGPATH getFileImgpath(){
		return  fileImgpath;
	}
	
	/**
	 * 设置 "附件图片文件路径" 值
	 */
	public void setFileImgpath(DE_FILE_IMGPATH fileImgpath) {
		if(fileImgpath == null){
			fileImgpath= DE_FILE_IMGPATH.getTemplateInstance();
		}
		recordChangeFlag(6);
		this.fileImgpath = fileImgpath;
	}
	
	/**
	 * 获取 "附件图片大小" 值
	 */	
	public DE_FILE_IMGSIZE getFileImgsize(){
		return  fileImgsize;
	}
	
	/**
	 * 设置 "附件图片大小" 值
	 */
	public void setFileImgsize(DE_FILE_IMGSIZE fileImgsize) {
		if(fileImgsize == null){
			fileImgsize= DE_FILE_IMGSIZE.getTemplateInstance();
		}
		recordChangeFlag(7);
		this.fileImgsize = fileImgsize;
	}
	
	/**
	 * 获取 "附件图片是否可用" 值
	 */	
	public DE_FILE_AVAILABLE getFileAvailable(){
		return  fileAvailable;
	}
	
	/**
	 * 设置 "附件图片是否可用" 值
	 */
	public void setFileAvailable(DE_FILE_AVAILABLE fileAvailable) {
		if(fileAvailable == null){
			fileAvailable= DE_FILE_AVAILABLE.getTemplateInstance();
		}
		recordChangeFlag(8);
		this.fileAvailable = fileAvailable;
	}
	
	/**
	 * 获取 "附件图片是否显示" 值
	 */	
	public DE_FILE_SFSHOW getFileSfshow(){
		return  fileSfshow;
	}
	
	/**
	 * 设置 "附件图片是否显示" 值
	 */
	public void setFileSfshow(DE_FILE_SFSHOW fileSfshow) {
		if(fileSfshow == null){
			fileSfshow= DE_FILE_SFSHOW.getTemplateInstance();
		}
		recordChangeFlag(9);
		this.fileSfshow = fileSfshow;
	}
	
	/**
	 * 获取 "附件图片操作时间" 值
	 */	
	public DE_FILE_OPPTIME getFileOpptime(){
		return  fileOpptime;
	}
	
	/**
	 * 设置 "附件图片操作时间" 值
	 */
	public void setFileOpptime(DE_FILE_OPPTIME fileOpptime) {
		if(fileOpptime == null){
			fileOpptime= DE_FILE_OPPTIME.getTemplateInstance();
		}
		recordChangeFlag(10);
		this.fileOpptime = fileOpptime;
	}


	@Override
	public BaseDataElement<?>[] fields(){
		return new BaseDataElement<?>[] {fileId,fileRelateddoctypeid,fileRelateddocstoreid,fileImgid,fileImgname,fileImgdomain,fileImgpath,fileImgsize,fileAvailable,fileSfshow,fileOpptime};
	}
	
	@Override
	public String[] fieldNames() {
		return new String[]{"fileId","fileRelateddoctypeid","fileRelateddocstoreid","fileImgid","fileImgname","fileImgdomain","fileImgpath","fileImgsize","fileAvailable","fileSfshow","fileOpptime"};
	}
	
	@Override
	public BaseDataElement<?> getFieldValue(String fieldName)  {
		if ("fileId".equals(fieldName)) {
			return fileId;
		}
		if ("fileRelateddoctypeid".equals(fieldName)) {
			return fileRelateddoctypeid;
		}
		if ("fileRelateddocstoreid".equals(fieldName)) {
			return fileRelateddocstoreid;
		}
		if ("fileImgid".equals(fieldName)) {
			return fileImgid;
		}
		if ("fileImgname".equals(fieldName)) {
			return fileImgname;
		}
		if ("fileImgdomain".equals(fieldName)) {
			return fileImgdomain;
		}
		if ("fileImgpath".equals(fieldName)) {
			return fileImgpath;
		}
		if ("fileImgsize".equals(fieldName)) {
			return fileImgsize;
		}
		if ("fileAvailable".equals(fieldName)) {
			return fileAvailable;
		}
		if ("fileSfshow".equals(fieldName)) {
			return fileSfshow;
		}
		if ("fileOpptime".equals(fieldName)) {
			return fileOpptime;
		}
 
		throw new IllegalArgumentException("PO对象中没有"+fieldName+"字段");
	}
	
	@Override
	public TFilePO setFieldValue(String fieldName, Object fieldValue) throws SwordBaseCheckedException {
		if (fieldValue != null && !(fieldValue instanceof BaseDataElement<?>)) {
			throw new SwordBaseCheckedException("字段值类型不是DataElelement子类型");
		}

		if ("fileId".equals(fieldName)) {
			if (fieldValue == null) {
				setFileId(null);
			} else {
				setFileId((DE_FILE_ID) fieldValue);
			}
			return this;
		}

		if ("fileRelateddoctypeid".equals(fieldName)) {
			if (fieldValue == null) {
				setFileRelateddoctypeid(null);
			} else {
				setFileRelateddoctypeid((DE_FILE_RELATEDDOCTYPEID) fieldValue);
			}
			return this;
		}

		if ("fileRelateddocstoreid".equals(fieldName)) {
			if (fieldValue == null) {
				setFileRelateddocstoreid(null);
			} else {
				setFileRelateddocstoreid((DE_FILE_RELATEDDOCSTOREID) fieldValue);
			}
			return this;
		}

		if ("fileImgid".equals(fieldName)) {
			if (fieldValue == null) {
				setFileImgid(null);
			} else {
				setFileImgid((DE_FILE_IMGID) fieldValue);
			}
			return this;
		}

		if ("fileImgname".equals(fieldName)) {
			if (fieldValue == null) {
				setFileImgname(null);
			} else {
				setFileImgname((DE_FILE_IMGNAME) fieldValue);
			}
			return this;
		}

		if ("fileImgdomain".equals(fieldName)) {
			if (fieldValue == null) {
				setFileImgdomain(null);
			} else {
				setFileImgdomain((DE_FILE_IMGDOMAIN) fieldValue);
			}
			return this;
		}

		if ("fileImgpath".equals(fieldName)) {
			if (fieldValue == null) {
				setFileImgpath(null);
			} else {
				setFileImgpath((DE_FILE_IMGPATH) fieldValue);
			}
			return this;
		}

		if ("fileImgsize".equals(fieldName)) {
			if (fieldValue == null) {
				setFileImgsize(null);
			} else {
				setFileImgsize((DE_FILE_IMGSIZE) fieldValue);
			}
			return this;
		}

		if ("fileAvailable".equals(fieldName)) {
			if (fieldValue == null) {
				setFileAvailable(null);
			} else {
				setFileAvailable((DE_FILE_AVAILABLE) fieldValue);
			}
			return this;
		}

		if ("fileSfshow".equals(fieldName)) {
			if (fieldValue == null) {
				setFileSfshow(null);
			} else {
				setFileSfshow((DE_FILE_SFSHOW) fieldValue);
			}
			return this;
		}

		if ("fileOpptime".equals(fieldName)) {
			if (fieldValue == null) {
				setFileOpptime(null);
			} else {
				setFileOpptime((DE_FILE_OPPTIME) fieldValue);
			}
			return this;
		}

		throw new SwordBaseCheckedException("PO对象中没有"+fieldName+"字段");
	}

	@Override
	protected TFilePO clone() {
		TFilePO t = new TFilePO();
		
		t.setFileId(this.fileId);
		t.setFileRelateddoctypeid(this.fileRelateddoctypeid);
		t.setFileRelateddocstoreid(this.fileRelateddocstoreid);
		t.setFileImgid(this.fileImgid);
		t.setFileImgname(this.fileImgname);
		t.setFileImgdomain(this.fileImgdomain);
		t.setFileImgpath(this.fileImgpath);
		t.setFileImgsize(this.fileImgsize);
		t.setFileAvailable(this.fileAvailable);
		t.setFileSfshow(this.fileSfshow);
		t.setFileOpptime(this.fileOpptime);

		return t;
	}

	@Override
	public TFilePO loadMap(Map<String, Object> dataMap) throws SwordBaseCheckedException {
		Object value = null;

		if(dataMap.containsKey("fileId")){
			value = dataMap.get("fileId");
			
			if (value == null) {
				this.setFileId(null);
			} else {
				if (value instanceof DE_FILE_ID) {
					this.setFileId((DE_FILE_ID) value);
				}
			    else {
					this.setFileId(new DE_FILE_ID(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("fileRelateddoctypeid")){
			value = dataMap.get("fileRelateddoctypeid");
			
			if (value == null) {
				this.setFileRelateddoctypeid(null);
			} else {
				if (value instanceof DE_FILE_RELATEDDOCTYPEID) {
					this.setFileRelateddoctypeid((DE_FILE_RELATEDDOCTYPEID) value);
				}
			    else {
					this.setFileRelateddoctypeid(new DE_FILE_RELATEDDOCTYPEID(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("fileRelateddocstoreid")){
			value = dataMap.get("fileRelateddocstoreid");
			
			if (value == null) {
				this.setFileRelateddocstoreid(null);
			} else {
				if (value instanceof DE_FILE_RELATEDDOCSTOREID) {
					this.setFileRelateddocstoreid((DE_FILE_RELATEDDOCSTOREID) value);
				}
			    else {
					this.setFileRelateddocstoreid(new DE_FILE_RELATEDDOCSTOREID(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("fileImgid")){
			value = dataMap.get("fileImgid");
			
			if (value == null) {
				this.setFileImgid(null);
			} else {
				if (value instanceof DE_FILE_IMGID) {
					this.setFileImgid((DE_FILE_IMGID) value);
				}
			    else {
					this.setFileImgid(new DE_FILE_IMGID(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("fileImgname")){
			value = dataMap.get("fileImgname");
			
			if (value == null) {
				this.setFileImgname(null);
			} else {
				if (value instanceof DE_FILE_IMGNAME) {
					this.setFileImgname((DE_FILE_IMGNAME) value);
				}
			    else {
					this.setFileImgname(new DE_FILE_IMGNAME(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("fileImgdomain")){
			value = dataMap.get("fileImgdomain");
			
			if (value == null) {
				this.setFileImgdomain(null);
			} else {
				if (value instanceof DE_FILE_IMGDOMAIN) {
					this.setFileImgdomain((DE_FILE_IMGDOMAIN) value);
				}
			    else {
					this.setFileImgdomain(new DE_FILE_IMGDOMAIN(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("fileImgpath")){
			value = dataMap.get("fileImgpath");
			
			if (value == null) {
				this.setFileImgpath(null);
			} else {
				if (value instanceof DE_FILE_IMGPATH) {
					this.setFileImgpath((DE_FILE_IMGPATH) value);
				}
			    else {
					this.setFileImgpath(new DE_FILE_IMGPATH(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("fileImgsize")){
			value = dataMap.get("fileImgsize");
			
			if (value == null) {
				this.setFileImgsize(null);
			} else {
				if (value instanceof DE_FILE_IMGSIZE) {
					this.setFileImgsize((DE_FILE_IMGSIZE) value);
				}
			    else {
					this.setFileImgsize(new DE_FILE_IMGSIZE(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("fileAvailable")){
			value = dataMap.get("fileAvailable");
			
			if (value == null) {
				this.setFileAvailable(null);
			} else {
				if (value instanceof DE_FILE_AVAILABLE) {
					this.setFileAvailable((DE_FILE_AVAILABLE) value);
				}
			    else {
					this.setFileAvailable(new DE_FILE_AVAILABLE(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("fileSfshow")){
			value = dataMap.get("fileSfshow");
			
			if (value == null) {
				this.setFileSfshow(null);
			} else {
				if (value instanceof DE_FILE_SFSHOW) {
					this.setFileSfshow((DE_FILE_SFSHOW) value);
				}
			    else {
					this.setFileSfshow(new DE_FILE_SFSHOW(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("fileOpptime")){
			value = dataMap.get("fileOpptime");
			
			if (value == null) {
				this.setFileOpptime(null);
			} else {
				if (value instanceof DE_FILE_OPPTIME) {
					this.setFileOpptime((DE_FILE_OPPTIME) value);
				}
				else if(value instanceof java.util.Date){
					this.setFileOpptime(new DE_FILE_OPPTIME((java.util.Date)value));
				}
			    else {
					this.setFileOpptime(new DE_FILE_OPPTIME(value.toString()));
				}
			}
		}

		return this;
	}
	
	@Override
	public Map<String,Object> toMap() {
		Map<String,Object> dataMap = new HashMap<String,Object>();

		dataMap.put("fileId", fileId);
		dataMap.put("fileRelateddoctypeid", fileRelateddoctypeid);
		dataMap.put("fileRelateddocstoreid", fileRelateddocstoreid);
		dataMap.put("fileImgid", fileImgid);
		dataMap.put("fileImgname", fileImgname);
		dataMap.put("fileImgdomain", fileImgdomain);
		dataMap.put("fileImgpath", fileImgpath);
		dataMap.put("fileImgsize", fileImgsize);
		dataMap.put("fileAvailable", fileAvailable);
		dataMap.put("fileSfshow", fileSfshow);
		dataMap.put("fileOpptime", fileOpptime);
		
		return dataMap;
	}
	
	@Override
	public Map<String,Object> toMapWithDEValue() {
		Map<String,Object> dataMap = new HashMap<String,Object>();

		dataMap.put("fileId", (fileId==null?null:fileId.value));
		dataMap.put("fileRelateddoctypeid", (fileRelateddoctypeid==null?null:fileRelateddoctypeid.value));
		dataMap.put("fileRelateddocstoreid", (fileRelateddocstoreid==null?null:fileRelateddocstoreid.value));
		dataMap.put("fileImgid", (fileImgid==null?null:fileImgid.value));
		dataMap.put("fileImgname", (fileImgname==null?null:fileImgname.value));
		dataMap.put("fileImgdomain", (fileImgdomain==null?null:fileImgdomain.value));
		dataMap.put("fileImgpath", (fileImgpath==null?null:fileImgpath.value));
		dataMap.put("fileImgsize", (fileImgsize==null?null:fileImgsize.value));
		dataMap.put("fileAvailable", (fileAvailable==null?null:fileAvailable.value));
		dataMap.put("fileSfshow", (fileSfshow==null?null:fileSfshow.value));
		dataMap.put("fileOpptime", (fileOpptime==null?null:fileOpptime.value));
		
		return dataMap;
	}
	
	@Override
	public TFilePO newInstance() {
		return new TFilePO();
	}
	
	@Override
	public String getTableName(){
		return TABLE_NAME;
	}
	
	@Override
	public BaseDataElement<?>[] getPrimaryKey() {
		return new BaseDataElement<?>[]{fileId};
	}

	@Override
	public void checkNotNull(byte sqlType) throws SwordBaseCheckedException {
		StringBuilder errorMsg = new StringBuilder();
		// insert
		if (sqlType == 0) {
				//只校验不可为空但又没有默认值的字段
				if (fileId.value == null && !HAS_DEFAULT_VALUE.get(0)) {
					errorMsg.append("字段fileId不允许为空\n");
				}

		}
		// update
		else if (sqlType == 1) {
		if (updateState.get(0) && fileId.value == null) {
			errorMsg.append("字段fileId不允许为空\n");
		}

		}
		
		if (errorMsg.length() > 0) {
			errorMsg.setLength(errorMsg.length() - 1);
			throw new SwordBaseCheckedException(errorMsg.toString());
		}
	}

	@Override
	public void updateLrrq(DateDE lrrq) {
	}

	@Override
	public void updateXgrq(DateDE xgrq) {
	}

	@Override
	public String toString() {
		StringBuilder str = new StringBuilder();
		str.append("fileId:").append(fileId.value!=null?fileId:"").append(" ").append("fileRelateddoctypeid:").append(fileRelateddoctypeid.value!=null?fileRelateddoctypeid:"").append(" ").append("fileRelateddocstoreid:").append(fileRelateddocstoreid.value!=null?fileRelateddocstoreid:"").append(" ").append("fileImgid:").append(fileImgid.value!=null?fileImgid:"").append(" ").append("fileImgname:").append(fileImgname.value!=null?fileImgname:"").append(" ").append("fileImgdomain:").append(fileImgdomain.value!=null?fileImgdomain:"").append(" ").append("fileImgpath:").append(fileImgpath.value!=null?fileImgpath:"").append(" ").append("fileImgsize:").append(fileImgsize.value!=null?fileImgsize:"").append(" ").append("fileAvailable:").append(fileAvailable.value!=null?fileAvailable:"").append(" ").append("fileSfshow:").append(fileSfshow.value!=null?fileSfshow:"").append(" ").append("fileOpptime:").append(fileOpptime.value!=null?fileOpptime:"").append(" ");
		return str.toString();
	}
	
}
